package com.example.springboot;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/api")
public class ProxyController {

    private final RestTemplate restTemplate = new RestTemplate();

    @GetMapping("/data")
    public ResponseEntity<String> getData() {
        String url = "https://echarts.apache.org/examples/data/asset/data/life-expectancy-table.json";
        return ResponseEntity.ok(restTemplate.getForObject(url, String.class));
    }

    @GetMapping("/flags")
    public ResponseEntity<String> getFlags() {
        String url = "https://fastly.jsdelivr.net/npm/emoji-flags@1.3.0/data.json";
        return ResponseEntity.ok(restTemplate.getForObject(url, String.class));
    }
}
